﻿using _15Net8AspNetCore_ORM_SqlSugar.Models;
using SqlSugar;

namespace _15Net8AspNetCore_ORM_SqlSugar.Context
{
    public class SqlSugarContext
    {
        public SqlSugarContext(IConfiguration configuration)
        {
            // 1、创建SqlSuggarClient
            _SqlSugarClient = new SqlSugarClient(
                new ConnectionConfig() { 
                    ConnectionString = configuration.GetConnectionString("DefaultConnection"),    
                    DbType = DbType.MySql,
                    IsAutoCloseConnection = true,
                });

            _SqlSugarClient.CodeFirst.InitTables<Order>();
        }

        public IConfiguration _Configuration { get; set; }

        public SqlSugarClient _SqlSugarClient { get; set; }

    }
}
